﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
using System.Net.Mail;


namespace CarRental.Utils {
    public class SendEmail {
        public void Sendmail(string pReceiver, string pSubject, string pBody) {
            // Gmail Address from where you send the mail
            var fromAddress = "a348652734568@gmail.com";
            // any address where the email will be sending
            var toAddress = pReceiver;
            //Password of your gmail address
            const string fromPassword = "aa123465";
            // Passing the values and make a email formate to display
            string subject = pSubject;
            string body = pBody;
            // smtp settings
            var smtp = new System.Net.Mail.SmtpClient();
            {
                smtp.Host = "smtp.gmail.com";
                smtp.Port = 587;
                smtp.EnableSsl = true;
                smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
                smtp.Timeout = 20000;
            }
            // Passing values to smtp object
            smtp.Send(fromAddress, toAddress, subject, body);


        }
    }
}
